package com.huawei.appmarket.service.push;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.TextView;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.downloadengine.api.SplitTask;
import com.huawei.appmarket.framework.activity.SecureActivity;
import com.huawei.appmarket.service.push.PushDownloadAlertActivityProtocol.Request;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import java.util.List;
import o.cud;
import o.dgm;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.dqw;
import o.dvt;
import o.ejf;
import o.ejj;
import o.epv;
import o.epw;
import o.CollectCheck;
import o.eqx;
import o.ewm.h;
import o.ewm.j;

public class PushDownloadAlertActivity extends SecureActivity<PushDownloadAlertActivityProtocol> {
    private String ʻॱ;
    private int ʼॱ = 0;
    private int ʿ = 0;
    private String ˊॱ;
    private String ˋॱ;
    private String ˏॱ;
    private String ͺ;
    private long ॱˊ = 0;
    private String ॱˋ;
    private String ॱˎ;
    private String ॱᐝ;
    private String ᐝॱ;

    static class b implements ejf {
        private SessionDownloadTask ˋ;

        public b(SessionDownloadTask sessionDownloadTask) {
            this.ˋ = sessionDownloadTask;
        }

        public void ˋ() {
            if (this.ˋ != null) {
                dvt.ˏ().ˏ(this.ˋ);
            }
        }

        public void ॱ() {
        }
    }

    static class c implements ejf {
        SessionDownloadTask ˋ;

        public c(SessionDownloadTask sessionDownloadTask) {
            this.ˋ = sessionDownloadTask;
        }

        public void ˋ() {
            dvt.ˏ().ˏ(this.ˋ);
        }

        public void ॱ() {
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ʼ();
    }

    public void onDestroy() {
        Logger.ˎ("pushAgentAlert", "entering onDestroy");
        super.onDestroy();
    }

    private void ʼ() {
        requestWindowFeature(1);
        setContentView(h.ʻʻ);
        LinearLayout linearLayout = (LinearLayout) findViewById(j.ᐧˊ);
        LayoutParams layoutParams = linearLayout.getLayoutParams();
        layoutParams.width = (int) (((double) epv.ˎ(this)) * 0.9d);
        linearLayout.setLayoutParams(layoutParams);
        PushDownloadAlertActivityProtocol pushDownloadAlertActivityProtocol = (PushDownloadAlertActivityProtocol) ʾ();
        if (pushDownloadAlertActivityProtocol == null || pushDownloadAlertActivityProtocol.ˊ() == null) {
            finish();
            return;
        }
        Request ˊ = pushDownloadAlertActivityProtocol.ˊ();
        this.ʻॱ = ˊ.ˋ();
        this.ᐝॱ = ˊ.ˎ();
        this.ॱˎ = ˊ.ˏ();
        this.ˊॱ = ˊ.ॱ();
        this.ॱˋ = ˊ.ˊ();
        this.ˋॱ = ˊ.ʽ();
        this.ˏॱ = ˊ.ˊॱ();
        this.ʿ = ˊ.ˏॱ();
        this.ʼॱ = ˊ.ॱˊ();
        if (dof.ʽ(this.ᐝॱ) || dof.ʽ(this.ˋॱ)) {
            finish();
            return;
        }
        this.ͺ = ˊ.ॱॱ();
        this.ॱᐝ = ˊ.ʻ();
        final String ͺ = ˊ.ͺ();
        float ᐝ = ˊ.ᐝ();
        boolean ʼ = ˊ.ʼ();
        setTitle(this.ʻॱ);
        TextView textView = (TextView) findViewById(j.ꓸʼ);
        TextView textView2 = (TextView) findViewById(j.ꜝᐝ);
        RatingBar ratingBar = (RatingBar) findViewById(j.ꜜ);
        eqx.ˏ((ImageView) findViewById(j.ꓸͺ), this.ॱᐝ, "defaultPresetResourceKey");
        textView.setText(this.ʻॱ);
        CharSequence charSequence = "";
        try {
            this.ॱˊ = Long.parseLong(this.ॱˋ);
            charSequence = epw.ˊ(this.ॱˊ);
        } catch (NumberFormatException e) {
            Logger.e("PushDownloadAlertActivity", "pushAppBySales(Intent i) " + e.toString());
        }
        textView2.setText(charSequence);
        ratingBar.setRating(ᐝ);
        if (ʼ) {
            ((Button) findViewById(j.ꜝˊ)).setOnClickListener(new OnClickListener(this) {
                final /* synthetic */ PushDownloadAlertActivity ˎ;

                public void onClick(View view) {
                    this.ˎ.ˏ(true, this.ˎ.ˋॱ, this.ˎ.ˏॱ, this.ˎ.ʻॱ, this.ˎ.ॱˎ, this.ˎ.ॱˊ, this.ˎ.ॱᐝ, this.ˎ.ᐝॱ, this.ˎ.ͺ, ͺ);
                    this.ˎ.finish();
                }
            });
            ((Button) findViewById(j.ꜝˋ)).setOnClickListener(new OnClickListener(this) {
                final /* synthetic */ PushDownloadAlertActivity ॱ;

                {
                    this.ॱ = r1;
                }

                public void onClick(View view) {
                    this.ॱ.finish();
                }
            });
            return;
        }
        ˏ(false, this.ˋॱ, this.ˏॱ, this.ʻॱ, this.ॱˎ, this.ॱˊ, this.ॱᐝ, this.ᐝॱ, this.ͺ, ͺ);
        finish();
    }

    private void ˏ(boolean z, String str, String str2, String str3, String str4, long j, String str5, String str6, String str7, String str8) {
        if (dof.ˋ(str4)) {
            ॱ(z, str, str2, str3, str4, j, str5, str6, str7);
            return;
        }
        final String str9 = str;
        final String str10 = str2;
        final long j2 = j;
        final String str11 = str4;
        final String str12 = str3;
        final String str13 = str5;
        final String str14 = str6;
        final String str15 = str7;
        final boolean z2 = z;
        new dqw().ˏ(dqw.ˊ(str4, this.ʼॱ, str8), new o.dqw.c(this) {
            final /* synthetic */ PushDownloadAlertActivity ॱॱ;

            public void ˋ(SessionDownloadTask sessionDownloadTask) {
                if (sessionDownloadTask != null) {
                    SplitTask splitTask;
                    if (this.ॱॱ.ʼॱ == 0) {
                        splitTask = new SplitTask();
                        splitTask.ˋ(str9);
                        splitTask.ˊ(str10);
                        splitTask.ˋ(j2);
                        splitTask.ˊॱ(str11);
                        sessionDownloadTask.ˏ(splitTask);
                    }
                    List<SplitTask> ᐝˊ = sessionDownloadTask.ᐝˊ();
                    if (!CollectCheck.isEmpty(ᐝˊ)) {
                        for (SplitTask splitTask2 : ᐝˊ) {
                            splitTask2.ˋ(splitTask2.ᐝ() + "source=" + this.ॱॱ.ˊॱ);
                        }
                    }
                    sessionDownloadTask.ʼ(str11);
                    sessionDownloadTask.ˊ(str9);
                    sessionDownloadTask.ॱॱ(str12);
                    sessionDownloadTask.ʽ(str13);
                    sessionDownloadTask.ॱ(str14);
                    sessionDownloadTask.ˏ(str15);
                    sessionDownloadTask.ˊ(dgm.ˎ(this.ॱॱ));
                    sessionDownloadTask.ॱ(this.ॱॱ.ʿ);
                    SessionDownloadTask ˋ = dvt.ˏ().ˋ(str11);
                    if (ˋ != null) {
                        dvt.ˏ().ˎ(ˋ);
                    } else if (z2) {
                        this.ॱॱ.ˋ(sessionDownloadTask);
                    } else {
                        this.ॱॱ.ॱ(sessionDownloadTask);
                    }
                }
            }

            public void ॱ() {
                Logger.e("PushDownloadAlertActivity", "startDownload get bundle info fail.");
            }
        });
    }

    private void ॱ(boolean z, String str, String str2, String str3, String str4, long j, String str5, String str6, String str7) {
        SessionDownloadTask sessionDownloadTask = new SessionDownloadTask();
        String str8 = cud.ˎ(str) + "source=" + this.ˊॱ;
        SplitTask splitTask = new SplitTask();
        splitTask.ˋ(str8);
        splitTask.ˊ(str2);
        splitTask.ˋ(j);
        sessionDownloadTask.ˏ(splitTask);
        sessionDownloadTask.ॱॱ(str3);
        sessionDownloadTask.ˊ(str8);
        if (dof.ˋ(str4)) {
            str4 = HiAnalyticsConstant.REPORT_VAL_SEPARATOR + str6;
        }
        sessionDownloadTask.ʼ(str4);
        splitTask.ˊॱ(str4);
        sessionDownloadTask.ʽ(str5);
        sessionDownloadTask.ॱ(str6);
        sessionDownloadTask.ˏ(str7);
        sessionDownloadTask.ˊ(dgm.ˎ(this));
        sessionDownloadTask.ॱ(this.ʿ);
        SessionDownloadTask ˋ = dvt.ˏ().ˋ(str4);
        if (ˋ != null) {
            dvt.ˏ().ˎ(ˋ);
        } else if (z) {
            ˋ(sessionDownloadTask);
        } else {
            ॱ(sessionDownloadTask);
        }
    }

    private void ˋ(SessionDownloadTask sessionDownloadTask) {
        if (ejj.ˊ().ˎ()) {
            ejj.ˊ().ˏ(ContentManager.getInstant().getContext(), new b(sessionDownloadTask));
            return;
        }
        dvt.ˏ().ˏ(sessionDownloadTask);
    }

    private void ॱ(SessionDownloadTask sessionDownloadTask) {
        if (ejj.ˊ().ˎ()) {
            ejj.ˊ().ˏ(ContentManager.getInstant().getContext(), new c(sessionDownloadTask));
            return;
        }
        dvt.ˏ().ˏ(sessionDownloadTask);
    }

    public void finish() {
        super.finish();
        Logger.ˎ("pushAgentAlert", "finish");
    }
}
